using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace WebDauGia.Domain.Models.Mapping
{
    public class ChiTietDonHangMap : EntityTypeConfiguration<ChiTietDonHang>
    {
        public ChiTietDonHangMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            // Table & Column Mappings
            this.ToTable("ChiTietDonHang");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.iddonhang).HasColumnName("iddonhang");
            this.Property(t => t.idsanpham).HasColumnName("idsanpham");
            this.Property(t => t.soluong).HasColumnName("soluong");
            this.Property(t => t.dongia).HasColumnName("dongia");

            // Relationships
            this.HasRequired(t => t.DonDatHang)
                .WithMany(t => t.ChiTietDonHangs)
                .HasForeignKey(d => d.iddonhang);
            this.HasRequired(t => t.SanPham)
                .WithMany(t => t.ChiTietDonHangs)
                .HasForeignKey(d => d.idsanpham);

        }
    }
}
